﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;


namespace ERP.Classes
{
    public class cs_hmr_hopdong_nhanvienInfo
    {
        private string _manv_hd;
        private int _manv;
        private string _maloaihd;
        private string _maloaild;
        private string _madv;
        private DateTime _ngaybatdau;
        private DateTime _ngayketthuc;
        private int _trangthaihd;
        private double _luongkhoan;
        private string _ngaynhap;
        private int _nguoinhap;
        private string _ngaysua;
        private int _nguoisua;
        private string _ghichu;

        
        public cs_hmr_hopdong_nhanvienInfo()
        {
            this._manv_hd = " ";
            this._manv = 0;
            this._maloaihd = " ";
            this._maloaild = " ";
            this._madv = " ";
            this._ngaybatdau = Convert.ToDateTime("01/01/9999");
            this._ngayketthuc = Convert.ToDateTime("01/01/9999");
            this._trangthaihd = 0;
            this._luongkhoan = 0;
            this._ngaynhap = " ";
            this._nguoinhap = 0;
            this._ngaysua = " ";
            this._nguoisua = 0;
            this._ghichu = " ";

        }
        public string manv_hd
        {
            get
            {
                return this._manv_hd;
            }
            set
            {
                this._manv_hd = value;
            }
        }
        public int manv
        {
            get
            {
                return this._manv;
            }
            set
            {
                this._manv = value;
            }
        }
        public string maloaihd
        {
            get
            {
                return this._maloaihd;
            }
            set
            {
                this._maloaihd = value;
            }
        }
        public string maloaild
        {
            get
            {
                return this._maloaild;
            }
            set
            {
                this._maloaild = value;
            }
        }
        public string madv
        {
            get
            {
                return this._madv;
            }
            set
            {
                this._madv = value;
            }
        }
        public DateTime ngaybatdau
        {
            get
            {
                return this._ngaybatdau;
            }
            set
            {
                this._ngaybatdau = value;
            }
        }
        public DateTime ngayketthuc
        {
            get
            {
                return this._ngayketthuc;
            }
            set
            {
                this._ngayketthuc = value;
            }
        }
        public int trangthaihd
        {
            get
            {
                return this._trangthaihd;
            }
            set
            {
                this._trangthaihd = value;
            }
        }
        public double luongkhoan
        {
            get
            {
                return this._luongkhoan;
            }
            set
            {
                this._luongkhoan = value;
            }
        }
        public string ngaynhap
        {
            get
            {
                return this._ngaynhap;
            }
            set
            {
                this._ngaynhap = value;
            }
        }
        public int nguoinhap
        {
            get
            {
                return this._nguoinhap;
            }
            set
            {
                this._nguoinhap = value;
            }
        }
        public string ngaysua
        {
            get
            {
                return this._ngaysua;
            }
            set
            {
                this._ngaysua = value;
            }
        }
        public int nguoisua
        {
            get
            {
                return this._nguoisua;
            }
            set
            {
                this._nguoisua = value;
            }
        }
        public string ghichu
        {
            get
            {
                return this._ghichu;
            }
            set
            {
                this._ghichu = value;
            }
        }

        public int ExcuteStoreProcedure(string storeProcedure, int option)
        {
            string[] paraName = new string[15];
            paraName[0] = "@manv_hd";
            paraName[1] = "@manv";
            paraName[2] = "@maloaihd";
            paraName[3] = "@maloaild";
            paraName[4] = "@madv";
            paraName[5] = "@ngaybatdau";
            paraName[6] = "@ngayketthuc";
            paraName[7] = "@trangthaihd";
            paraName[8] = "@luongkhoan";
            paraName[9] = "@ngaynhap";
            paraName[10] = "@nguoinhap";
            paraName[11] = "@ngaysua";
            paraName[12] = "@nguoisua";
            paraName[13] = "@ghichu";
            paraName[14] = "@option";
            object[] paraValue = new object[15];
            paraValue[0] = this._manv_hd;
            paraValue[1] = this._manv;
            paraValue[2] = this._maloaihd;
            paraValue[3] = this._maloaild;
            paraValue[4] = this._madv;
            paraValue[5] = this._ngaybatdau;
            paraValue[6] = this._ngayketthuc;
            paraValue[7] = this._trangthaihd;
            paraValue[8] = this._luongkhoan;
            paraValue[9] = this._ngaynhap;
            paraValue[10] = this._nguoinhap;
            paraValue[11] = this._ngaysua;
            paraValue[12] = this._nguoisua;
            paraValue[13] = this._ghichu;
            paraValue[14] = option;
            csCSDL csdl = new csCSDL();
            int i = 0;
            i = csdl.CreateParameters(paraName, 15, paraValue);
            return csdl.ExcuteStoreProcedure(storeProcedure);
        }
        public void KetDulieuVaoListview(ListView myList)
        {
            csListView list = new csListView();
            string[] fields = new string[14];
            fields[0] = "manv_hd";
            fields[1] = "manv";
            fields[2] = "maloaihd";
            fields[3] = "maloaild";
            fields[4] = "madv";
            fields[5] = "ngaybatdau";
            fields[6] = "ngayketthuc";
            fields[7] = "trangthaihd";
            fields[8] = "luongkhoan";
            fields[9] = "ngaynhap";
            fields[10] = "nguoinhap";
            fields[11] = "ngaysua";
            fields[12] = "nguoisua";
            fields[13] = "ghichu";
            list.KetDulieu(myList, "HMR_HOPDONG_NHANVIEN", "", fields);
        }
        public int ExcuteProcedure(int option)
        {
            return this.ExcuteStoreProcedure("Proc_HMR_HOPDONG_NHANVIEN", option);
        }

        public void ShowDataInCombo(ComboBox cbo, string condition)
        {
            csComboBox cb = new csComboBox("manv", "manv_hd");
            cb.KetDuLieu(cbo, "HMR_HOPDONG_NHANVIEN", condition);
        }

        public int ShowDataGrid(DataGrid datagrid, string condition)
        {
            csDataGrid grid = new csDataGrid();

            string[] header = new string[14];
            header[0] = "manv_hd";
            header[1] = "manv";
            header[2] = "maloaihd";
            header[3] = "maloaild";
            header[4] = "madv";
            header[5] = "ngaybatdau";
            header[6] = "ngayketthuc";
            header[7] = "trangthaihd";
            header[8] = "luongkhoan";
            header[9] = "ngaynhap";
            header[10] = "nguoinhap";
            header[11] = "ngaysua";
            header[12] = "nguoisua";
            header[13] = "ghichu";

            string[] mappingname = new string[14];
            mappingname[0] = "manv_hd";
            mappingname[1] = "manv";
            mappingname[2] = "maloaihd";
            mappingname[3] = "maloaild";
            mappingname[4] = "madv";
            mappingname[5] = "ngaybatdau";
            mappingname[6] = "ngayketthuc";
            mappingname[7] = "trangthaihd";
            mappingname[8] = "luongkhoan";
            mappingname[9] = "ngaynhap";
            mappingname[10] = "nguoinhap";
            mappingname[11] = "ngaysua";
            mappingname[12] = "nguoisua";
            mappingname[13] = "ghichu";

            int[] colwidth = new int[14];
            colwidth[0] = 60;
            colwidth[1] = 12;
            colwidth[2] = 30;
            colwidth[3] = 30;
            colwidth[4] = 30;
            colwidth[5] = 24;
            colwidth[6] = 24;
            colwidth[7] = 12;
            colwidth[8] = 24;
            colwidth[9] = 90;
            colwidth[10] = 12;
            colwidth[11] = 90;
            colwidth[12] = 12;
            colwidth[13] = 2400;
            csCSDL csdl = new csCSDL();
            return grid.CreateTableStyle("HMR_HOPDONG_NHANVIEN", datagrid, csdl.OpenTable("HMR_HOPDONG_NHANVIEN", condition), header, mappingname, colwidth, 14);
        }
        public int Get_Info()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                ds = csdl.OpenTable("HMR_HOPDONG_NHANVIEN", "manv_hd = '" + this._manv_hd + "'");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                this._manv_hd = ds.Tables[0].Rows[0]["manv_hd"].ToString().Trim();
                this._manv = Convert.ToInt32(ds.Tables[0].Rows[0]["manv"].ToString().Trim());
                this._maloaihd = ds.Tables[0].Rows[0]["maloaihd"].ToString().Trim();
                this._maloaild = ds.Tables[0].Rows[0]["maloaild"].ToString().Trim();
                this._madv = ds.Tables[0].Rows[0]["madv"].ToString().Trim();
                this._ngaybatdau = Convert.ToDateTime(ds.Tables[0].Rows[0]["ngaybatdau"].ToString().Trim());
                this._ngayketthuc = Convert.ToDateTime(ds.Tables[0].Rows[0]["ngayketthuc"].ToString().Trim());
                this._trangthaihd = Convert.ToInt32(ds.Tables[0].Rows[0]["trangthaihd"].ToString().Trim());
                this._luongkhoan = Convert.ToDouble(ds.Tables[0].Rows[0]["luongkhoan"].ToString().Trim());
                this._ngaynhap = ds.Tables[0].Rows[0]["ngaynhap"].ToString().Trim();
                this._nguoinhap = Convert.ToInt32(ds.Tables[0].Rows[0]["nguoinhap"].ToString().Trim());
                this._ngaysua = ds.Tables[0].Rows[0]["ngaysua"].ToString().Trim();
                this._nguoisua = Convert.ToInt32(ds.Tables[0].Rows[0]["nguoisua"].ToString().Trim());
                this._ghichu = ds.Tables[0].Rows[0]["ghichu"].ToString().Trim();
                return 1;
            }
            catch
            {
                return -1;
            }
        }
    }
}
